package edu.java.homework.hw10.tests;

//5.23


class AB {
    void f() throws ArithmeticException {
	// ...
    }
}


public class MyClass6 extends AB {
    void f() throws 	ArrayIndexOutOfBoundsException {	// InterruptedException{ 		//
	// InterruptedException å äèðåêòåí ïîäêëàñ íà Exception

	throw new ArrayIndexOutOfBoundsException();
    }

    public static void main(String[] args) {
	AB obj = new MyClass6();
	try {
	    obj.f();
	} catch (ArithmeticException e) {
	    System.out.println(e);
	    throw new RuntimeException("Something wrong here");
	}
	catch(ArrayIndexOutOfBoundsException e){
	    System.out.println("here ");
	}
	System.out.println("finish");
    }
}

/*
 * Êàêúâ ïðîáëåì (-è) ùå âúçíèêíå ñ ãîðíèÿ êîä? à) â ìåòîäà main òðÿáâà äà ñå
 * äåêëàðèðà, ÷å õâúðëÿ RuntimeException; b) ìåòîäúò f â êëàñ MyClass6, òðÿáâà
 * äà äåêëàðèðà throws ArithmeticException, òúé êàòî òàêàâà å äåêëàðàöèÿòà â
 * ìåòîäà êîéòî ïðåäåôèíèðà îò êëàñà A; c)
 */

// a) uncorrect
// b) F-method in MyClass6 has to declare that throws ArithmeticException OR
// some subclass of ArithmeticException.